//supply类型的需求按钮的功能实现，与buttonSupply.vue绑定

import store from "@/store";

export function dealSupplyRequest(request){
    switch(request){
        case '毛巾': dealTowel(); break;
        case '水壶': dealKettle(); break;
        case '牙刷': dealToothBrush(); break;
        case '拖鞋': dealSlipper(); break;
        default: return;
    }
}

function dealTowel(){
    let roomNumber = store.getters.getRoomNumber;
    if(roomNumber!='default'){   
        store.dispatch('sendMessage', {       
            text: '正在为您配送，请耐心等待', 
            receiver: true, 
            request:'default'},
        )
        console.log("deal with request for towel");
    }else{
        store.dispatch('sendRequest', '毛巾');
        store.dispatch('sendMessage', {       
            text: '输入房间号', 
            receiver: true, 
            request:'房间号'},
        )   
    }
}

function dealKettle(){
    let roomNumber = store.getters.getRoomNumber;
    if(roomNumber!='default'){  
        store.dispatch('sendMessage', {       
            text: '正在为您配送，请耐心等待', 
            receiver: true, 
            request:'default'},
        ) 
        console.log("deal with request for kettle");
    }else{
        store.dispatch('sendRequest', '水壶');
        store.dispatch('sendMessage', {       
            text: '输入房间号', 
            receiver: true, 
            request:'房间号'},
        )   
    }
}

function dealToothBrush(){
    let roomNumber = store.getters.getRoomNumber;
    if(roomNumber!='default'){  
        store.dispatch('sendMessage', {       
            text: '正在为您配送，请耐心等待', 
            receiver: true, 
            request:'default'},
        ) 
        console.log("deal with request for tooth-brush");
    }else{
        store.dispatch('sendRequest', '洗漱用品');
        store.dispatch('sendMessage', {       
            text: '输入房间号', 
            receiver: true, 
            request:'房间号'},
        )   
    }
}

function dealSlipper(){
    let roomNumber = store.getters.getRoomNumber;
    if(roomNumber!='default'){  
        store.dispatch('sendMessage', {       
            text: '正在为您配送，请耐心等待', 
            receiver: true, 
            request:'default'},
        ) 
        console.log("deal with request for slipper");
    }else{
        store.dispatch('sendRequest', '拖鞋');
        store.dispatch('sendMessage', {       
            text: '输入房间号', 
            receiver: true, 
            request:'房间号'},
        )   
    }
}